
#include "King.h"

King::King(bool white): Piece(white) {
}

std::string King::GetType() const{
   return "king";
}

std::set<BoardPosition> King::GetAllMoves(Board * b, BoardPosition curPos) {

   std::set<BoardPosition> ReturnSet;

   for (int i=-1; i <2; i++) {
      for (int j=-1; j<2; j++) {
         BoardPosition pos(curPos.GetRow()+i, curPos.GetCol()+j);
         if (pos.IsOnBoard())
            ReturnSet.insert(pos);
      }
   }

   return ReturnSet;
}

std::set<BoardPosition> King::GetLegalMoves(Board * b, BoardPosition curPos) {

   std::set<BoardPosition> ReturnSet;

   for (int i=-1; i <2; i++) {
      for (int j=-1; j<2; j++) {
         BoardPosition pos(curPos.GetRow()+i, curPos.GetCol()+j);
         if (pos.IsOnBoard())
            ReturnSet.insert(pos);
      }
   }

   return ReturnSet;
}